function [idx, ctrs]=kmeasLocate(Vin, number)
%KMEANSLOCATE A function used to locate substations
%	Input: substation numbers; consumer locations with loads
%	Output:	substation locations (line: substation number  column:2)
%	August 7 2014, RIsoe Denmark, Qin Wang

opts = statset('Display','final');

[idx,ctrs] = kmeans(Vin(:,1:2),number,...
                    'Distance','city',...
                    'Replicates',5,...
                    'Options',opts);
plot(Vin(idx==1,1),Vin(idx==1,2),'r.','MarkerSize',12)
hold on
plot(Vin(idx==2,1),Vin(idx==2,2),'b.','MarkerSize',12)
plot(Vin(idx==3,1),Vin(idx==3,2),'g.','MarkerSize',12)

plot(ctrs(:,1),ctrs(:,2),'kx',...
     'MarkerSize',12,'LineWidth',2)
plot(ctrs(:,1),ctrs(:,2),'ko',...
     'MarkerSize',12,'LineWidth',2)
legend('Cluster 1','Cluster 2','Cluster 2','Centroids',...
       'Location','NW')